package com.bodu.system.service.impl;

import com.bodu.core.entity.ParamReq;
import com.bodu.system.entity.po.DicPo;
import com.bodu.system.entity.request.DicRequest;
import com.bodu.system.entity.vo.DicVo;
import com.bodu.system.mapper.DicMapper;
import com.bodu.system.service.DicService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * 字典表 Service impl
 *
 * @author Administrator
 */
@Service
public class DicServiceImpl implements DicService {

    @Resource
    private DicMapper dicMapper;

    @Override
    public DicVo getModel(Long id) {
        DicVo dicVo = new DicVo();
        DicPo dicPo = dicMapper.getModel(id);
        BeanUtils.copyProperties(dicPo, dicVo);
        return dicVo;
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Long save(DicRequest request) {
        return dicMapper.save(request);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Long update(DicRequest request) {
        return dicMapper.update(request);
    }

    @Override
    public List<DicVo> listPage(ParamReq<DicRequest> params) {
        return dicMapper.listPage(params);
    }

    @Override
    public Integer countPage(ParamReq<DicRequest> params) {
        return dicMapper.countPage(params);
    }

    @Override
    public Integer updateDelFlagById(Long id, Integer delFlag) {
        return dicMapper.updateDelFlagById(id, delFlag);
    }

}
